<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">房间标题:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-h_title" data-rule="required" class="form-control" name="row[h_title]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">房牌编号:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="h_housebrand" data-rule="required" class="form-control" name="row[h_housebrand]" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择酒店:</label>
        <div class="col-xs-12 col-sm-8">

            <select id="c-type" data-rule="required" class="form-control" name="row[h_id]" onchange="show_sub(this.options[this.options.selectedIndex].value)">
                {foreach name="hotelList" item="vo"}
                  <option value="{$vo.id}">{$vo.h_title}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择楼层[单元]:</label>
        <div class="col-xs-12 col-sm-8">

            <select id="c-h_storey" data-rule="required" class="form-control" name="row[h_storey]">
                {foreach name="hotelNumArr" item="vo"}
                <option value="{$vo}">{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单价[时]:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-h_price" data-rule="required" class="form-control" step="0.01" name="row[h_price]" type="number" value="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">房间总价:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-h_allprice" data-rule="required" class="form-control" step="0.01" name="row[h_allprice]" type="number" value="0.00">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">入住须知:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-h_read" class="form-control " rows="5" name="row[h_read]" cols="50"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">房间设施:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="col-xs-12 col-sm-8">
                {foreach $serviceList as $key=>$vo}
                <label class="checkbox-inline checkbox" style="line-height: 24px;">
                    <input type="checkbox"   name="h_service[]" checked value="{$key}"> {$vo}
                </label>
                {/foreach}
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="c-editor" class="control-label col-xs-12 col-sm-2">房间详情:</label>

            <div class="col-xs-12 col-sm-8">
                <textarea name="row[h_content]" id="c-editor" cols="60" rows="5" class="form-control editor"></textarea>
            </div>

    </div>


    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script>
    //下拉框切换
    function show_sub(v){
        $.ajax({
            type: "POST",
            url: "house/AjaxHotelNum",
            data: {hotelid:v},
            dataType: "json",
            success: function(data){
                if(data["msg"] == "error"){
                    $('#c-h_storey').empty();   //清空resText里面的所有内容
                    layer.alert("酒店楼层数据有误,请检查酒店参数");
                    return
                }else{
                    $('#c-h_storey').empty();   //清空resText里面的所有内容
                    var html = '';
                    $.each(data.data, function(commentIndex, comment){
                        html += '<option value="'+ comment +'">'+ comment +'</option>';
                    });
                    $('#c-h_storey').html(html);
                }





            }
        });
    }

</script>
